import Qt 4.7

Rectangle {
    id: mainContainer
    width: 290; height: 30
    color: "transparent"

    property alias dropDownState: dateMode.state
    signal changedDate

    function updatePeriods() {
        dateMode.model = daoManager.getAllDatePeriods()
        dateMode.textSelected = daoManager.currentDate();
    }

    Image {
        id: rowNext

        x: 270; y :5
        width: 20; height: 30
        source: "../resources/pixmaps/seta1.png"
        visible: dateMode.state == 'normal'

        MouseArea {
            anchors.fill: parent
            onClicked: { dateMode.textSelected = daoManager.nextDate(); mainContainer.changedDate() }
        }
    }
    Image {
        id: rowPrevious

        x: 0; y :5
        width: 20; height: 30
        source: "../resources/pixmaps/seta2.png"
        visible: dateMode.state == 'normal'

        MouseArea {
            anchors.fill: parent
            onClicked: { dateMode.textSelected = daoManager.previousDate(); mainContainer.changedDate() }
        }
    }

    AdvancedDropDown {
        id: dateMode

        x: 20; y: 0
        rowTextX: 20
        rowVisible: false
        color: "transparent"
        fontPointSize: 7
        allowCreate: false
        width: 250; height: parent.height
        internalListWidth: 200
        internalWidth: parent.width; normalWidth: parent.width; extendedWidth: parent.width
        onItemSelected: {
            console.debug("QML:DateSelector - BEGIN GETTING " + textSelected);
            daoManager.setTypeDate(idSelected);
            mainContainer.changedDate();
            console.debug("QML:DateSelector - END GETTING " + textSelected);
        }
    }

}
